package com.code.enums;

import com.code.exception.CodeGenerateException;

import java.util.stream.Stream;

public enum CodeGenerateProviderType {

    VELOCITY("VELOCITY", 0);

    private String name;
    private int value;

    CodeGenerateProviderType(String name, int value) {
        this.name = name;
        this.value = value;
    }

    public static CodeGenerateProviderType of(int value) {
        return Stream.of(values())
            .filter(codeGenerateProviderType -> codeGenerateProviderType.getValue() == value)
            .findFirst()
            .orElseThrow(() -> new CodeGenerateException("不支持的代码生成策略!"));
    }

    public String getName() {
        return name;
    }

    public int getValue() {
        return value;
    }

}
